/**
 * @file vtm88637a.c
 * @brief vtm88637a LCM Parameters using st7576 IC
 *
 * @author yemt@witsi.cn
 * @date 2012-10-10
 * @version vtm88637a.01
 */
#include <stdint.h>
#include "ioctl.h"

const uint8_t lcd_init_cmd[] = {
        0xE2, /* Soft reset */
        0xFF, /* Delay */
        0x0A, /* 10ms */
        0xA3, /* Set Bias: 0xA3 1/7bias,0xA2 1/9 bias */
        0xA1, /* SEG Direction Select: b[0] = 0 normal, b[0] = 1 reverse */
        0xC0, /* COM Direction Select: b[3] = 0 normal, b[3] = 1 reverse */
        0xA6, /* Inverse Display: b[0] = 0 normal, b[0] = 1 inverse */
        0xA4, /* All pixel ON: b[0] = 0 normal, b[0] = 1 set all pixel ON */
        0x25, /* Regulation Ratio */
        0x81, /* Set Contrast (Electronic Volume Level) with the next cmd */
        0x30, /* EV[5:0] */
        0x2F, /* Power Control Set */
        0xFF, /* Delay */
        40,   /* 40ms */
        0x80, /* Set Display Start Line */
        0xAF, /* Display On */
        0x00,
};

const uint8_t lcd_x_ofs = 0;
const uint8_t lcd_y_ofs = 0;
extern int lcd_write_reg(uint32_t reg);
extern int lcd_write_data(uint32_t x, uint32_t y, uint32_t data);

int lcd_disp_attribute(uint32_t cmd,void *arg)
{
	switch (cmd&0xff) {
        	case IOCTL_LCD_ATTRIBUTE_GRAY:
                {
                        uint32_t per = (uint32_t )arg;
                        if(per>100) per = 63;
                        else per = (per*63)/100;
						lcd_write_reg(0x81);
						lcd_write_reg(per);
               	 }
                break;
		case IOCTL_LCD_ATTRIBUTE_TITLE:
                {
                        lcd_title_t* pStu = (lcd_title_t*)arg;
                       	title_control(pStu->index,pStu->flag); 
                }
                break;
			default:
				return -2;
	}
	return 0;
}

